package com.sds.smarthome.foundation.entity;

import com.sds.sdk.android.sh.common.SHClientState;

/**
 * Created by L on 2016/6/17.
 */
public enum SmartHomeConnectStatus {

    CONNECTING, CONNECTED, DATA_SYNCHRONIZED, DISCONNECTED;

    public static SmartHomeConnectStatus getStatus(SHClientState state) {
        if (state.ordinal() <= SHClientState.CLIENT_LOGINING.ordinal())
            return CONNECTING;
        else if (state == SHClientState.CLIENT_LONIN_FINISH_OK)
            return CONNECTED;
        else if (state == SHClientState.CLIENT_LONIN_FINISH_FAILED || state == SHClientState.LINK_BROKN)
            return DISCONNECTED;
        else if (state == SHClientState.CLIENT_SYNCH_FINISH_FAILED
                || state == SHClientState.CLIENT_WORKING)
            return DATA_SYNCHRONIZED;

        return CONNECTING;
    }
}
